//
//  JNetManager.m
//  HeadIndustry
//
//  Created by jun on 2017/8/28.
//  Copyright © 2017年 jun. All rights reserved.
//

#import "JNetManager.h"
#import <AFNetworking.h>

@implementation JNetManager

- (void)requestWihtMethod:(RequestMethodType)methodType
                      url:(NSString *)url
//                Operation:(NSString *)strOpt
//                  Handler:(NSString *)strHdr
               JsonString:(NSDictionary *)dicJson
                  success:(void (^)(id response))success
                  failure:(void (^)(NSError *err))failure {
    
    //    [self isHaveNetwork];
    
    NSURL* baseURL = [NSURL URLWithString:JNetAPI];
//
//    // /先导入证书
//    NSString *cerPath = [[NSBundle mainBundle] pathForResource:Certificate ofType:@"cer"];//证书的路径
//    NSData *certData = [NSData dataWithContentsOfFile:cerPath];
    
    // AFSSLPinningModeCertificate 使用证书验证模式
//    AFSecurityPolicy *securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate];
    
    // allowInvalidCertificates 是否允许无效证书（也就是自建的证书），默认为NO
    // 如果是需要验证自建证书，需要设置为YES
//    securityPolicy.allowInvalidCertificates = YES;
    
    //validatesDomainName 是否需要验证域名，默认为YES；
    //假如证书的域名与你请求的域名不一致，需把该项设置为NO；如设成NO的话，即服务器使用其他可信任机构颁发的证书，也可以建立连接，这个非常危险，建议打开。
    //置为NO，主要用于这种情况：客户端请求的是子域名，而证书上的是另外一个域名。因为SSL证书上的域名是独立的，假如证书上注册的域名是www.google.com，那么mail.google.com是无法验证通过的；当然，有钱可以注册通配符的域名*.google.com，但这个还是比较贵的。
    //如置为NO，建议自己添加对应域名的校验逻辑。
//    securityPolicy.validatesDomainName = NO;
    
//    securityPolicy.pinnedCertificates = @[certData];
    
//    securityPolicy.allowInvalidCertificates = YES;
    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:baseURL];
    
//    mgr.securityPolicy = securityPolicy;
     
    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 20.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
    manager.responseSerializer = [AFJSONResponseSerializer serializer];
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
#ifdef ContentType2
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
#endif
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
//    manager.requestSerializer.timeoutInterval = 30;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
    //dict转jsonDat
    
    switch (methodType) {
        case RequestMethodTypeGet: {
            //GET请求
            [manager GET:url parameters:dicJson progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
                if (success) {
                    success(responseObject);
                }
            } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
                if (failure) {
                    failure(error);
                }
            }];
            break;
        }
        case RequestMethodTypePost: {
            //POST请求
            //            NSLog(@"dicPara=======%@",dicPara);
            [manager POST:url parameters:dicJson progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
                if (success) {
                    success(responseObject);
                }
            } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
                if (failure) {
                    failure(error);
                }
            }];
            break;
        }
        default:
            break;
    }
    
}

+ (void)requestWihtMethod:(RequestMethodType)methodType
                      url:(NSString *)url
//                Operation:(NSString *)strOpt
//                  Handler:(NSString *)strHdr
               JsonString:(NSDictionary *)dicJson
                  success:(void (^)(id response))success
                  failure:(void (^)(NSError *err))failure {
    
    JNetManager *tool = [[JNetManager alloc]init];
    
    AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager];
    [manager startMonitoring];
    
    [manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        
        //        // 当网络状态改变时调用
        //        switch (status) {
        //            case AFNetworkReachabilityStatusUnknown:
        //                NSLog(@"未知网络");
        //                break;
        //            case AFNetworkReachabilityStatusNotReachable:
        //                NSLog(@"没有网络");
        //                break;
        //            case AFNetworkReachabilityStatusReachableViaWWAN:
        //                NSLog(@"手机自带网络");
        //                break;
        //            case AFNetworkReachabilityStatusReachableViaWiFi:
        //                NSLog(@"WIFI");
        //                break;
        //        }

        
        if (status == AFNetworkReachabilityStatusNotReachable) {

//            kHUDNormal(@"当前手机无网络，请检查网络")
            return;
        } else {
            
            [tool requestWihtMethod:methodType
                                url:url
//                          Operation:strOpt
//                            Handler:strHdr
                         JsonString:dicJson
                            success:success
                            failure:failure];
        }
    }];
    
//    [manager startMonitoring];
    
}

/// 发送验证码
+ (void)sendCodeToTelURL:(NSString *)url
                     tel:(NSString *)tel
                 success:(void (^)(id response))success
                 failure:(void (^)(NSString *err))failure
{
//    NSString *url = @"BusinessSettled/GetBusinessSettledCheckCode";
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    
    NSDictionary *dic = @{@"Tel":tel};
    
    [self requestWihtMethod:RequestMethodTypePost url:dataURL JsonString:dic success:^(id response) {
        if (response) {
            NSInteger nStatus = [response[@"suc"] integerValue];
            
            if (nStatus == 1) {
//                // 列表数据
//                NSEnumerator *enumertor = [response[@"data"] objectEnumerator];
//                NSDictionary *itemData;
//                NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
//                
//                while (itemData = (NSDictionary *)[enumertor nextObject]) {
//                    JAdviceModel *object = [[JAdviceModel alloc] init];
//                    [object setValuesForKeysWithDictionary:itemData];
//                    [mArrObject addObject:object];
//                }
                
                if (success) {
                    dispatch_async(dispatch_get_main_queue(), ^{
                        success(response[@"msg"]);
                    });
                }
                
            }else {
                NSString *strException = [NSString stringWithFormat:@"%@", response[@"msg"]];
                dispatch_async(dispatch_get_main_queue(), ^{
                    failure(strException);
                });
            }
        }
    } failure:^(NSError *err) {
        NSString *strException = @"网络请求失败";
        dispatch_async(dispatch_get_main_queue(), ^{
            failure(strException);
        });
    }];
    
    
}

/// 注册
+ (void)registRequestURL:(NSString *)url
               parperDic:(NSDictionary *)dic
                 success:(void (^)(id response))success
                 failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    
//    NSDictionary *dic = @{@"Tel":tel};
    
    [self requestWihtMethod:RequestMethodTypePost url:dataURL JsonString:dic success:^(id response) {
        if (response) {
            NSInteger nStatus = [response[@"suc"] integerValue];
            
            if (nStatus == 1) {
                //                // 列表数据
                //                NSEnumerator *enumertor = [response[@"data"] objectEnumerator];
                //                NSDictionary *itemData;
                //                NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
                //
                //                while (itemData = (NSDictionary *)[enumertor nextObject]) {
                //                    JAdviceModel *object = [[JAdviceModel alloc] init];
                //                    [object setValuesForKeysWithDictionary:itemData];
                //                    [mArrObject addObject:object];
                //                }
                
                if (success) {
                    dispatch_async(dispatch_get_main_queue(), ^{
                        success(@1);
                    });
                }
                
            }else {
                NSString *strException = [NSString stringWithFormat:@"%@", response[@"msg"]];
                dispatch_async(dispatch_get_main_queue(), ^{
                    failure(strException);
                });
            }
        }
    } failure:^(NSError *err) {
        NSString *strException = @"网络请求失败";
        dispatch_async(dispatch_get_main_queue(), ^{
            failure(strException);
        });
    }];
}

/// 登陆
+ (void)loginRequestURL:(NSString *)url
              parperDic:(NSDictionary *)dic
                success:(void (^)(id response))success
                failure:(void (^)(NSString *err))failure
{
    
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    
    //    NSDictionary *dic = @{@"Tel":tel};
//    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:dataURL]];
//    
//    manager.requestSerializer = [AFJSONRequestSerializer serializer];
//    manager.responseSerializer = [AFJSONResponseSerializer serializer];
//    
//    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
//    manager.securityPolicy.allowInvalidCertificates = YES;
//    manager.securityPolicy.validatesDomainName = NO;
//    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
//    manager.requestSerializer.timeoutInterval = 20.f;
//    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
//    
//    //关闭缓存避免干扰测试
//    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
//    
//#ifdef ContentType2
//    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
//#endif
//    manager.requestSerializer.HTTPShouldHandleCookies = YES;
//    //    manager.requestSerializer.timeoutInterval = 30;
//    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
//    
//    [manager POST:dataURL parameters:dic
//         progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//             if (responseObject) {
//                 NSInteger nStatus = [responseObject[@"suc"] integerValue];
//                 
//                 if (nStatus == 1) {
//                     
//                     //            NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
//                     NSDictionary *itemData = responseObject[@"data"];
//                     //            NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
//                     //
//                     //            while (itemData = (NSDictionary *)[enumertor nextObject]) {
//                     JUserInfoModel *object = [JUserInfoModel new];
//                     [object setValuesForKeysWithDictionary:itemData];
//                     object.CustomerId = object.Id;
//                     
//                     [GLOBALDATA setUserInfoModel:object];
//                     //                [mArrObject addObject:object];
//                     //            }
//                     
//                     if (success) {
//                         dispatch_async(dispatch_get_main_queue(), ^{
//                             success(object);
//                         });
//                     }
//                     
//                 }else {
//                     NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
//                     dispatch_async(dispatch_get_main_queue(), ^{
//                         failure(strException);
//                     });
//                 }
//             }
//         } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//             NSString *strException = @"网络请求失败";
//             dispatch_async(dispatch_get_main_queue(), ^{
//                 failure(strException);
//             });
//         }];
    
    [self requestWihtMethod:RequestMethodTypePost url:dataURL JsonString:dic success:^(id response) {
        if (response) {
            NSInteger nStatus = [response[@"suc"] integerValue];
            
            if (nStatus == 1) {
                
                //            NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
                NSDictionary *itemData = response[@"data"];
                //            NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
                //
                //            while (itemData = (NSDictionary *)[enumertor nextObject]) {
                JUserInfoModel *object = [JUserInfoModel new];
                [object setValuesForKeysWithDictionary:itemData];
                object.CustomerId = object.Id;
                
                [GLOBALDATA setUserInfoModel:object];
                //                [mArrObject addObject:object];
                //            }
                
                if (success) {
                    dispatch_async(dispatch_get_main_queue(), ^{
                        success(object);
                    });
                }
                
            }else {
                NSString *strException = [NSString stringWithFormat:@"%@", response[@"msg"]];
                dispatch_async(dispatch_get_main_queue(), ^{
                    failure(strException);
                });
            }
        }
    } failure:^(NSError *err) {
        NSString *strException = @"网络请求失败";
        dispatch_async(dispatch_get_main_queue(), ^{
            failure(strException);
        });
    }];
//
    
}
/// 秒杀图加载
+ (void)LoadKillProductImgUrl:(NSString *)url
                      success:(void (^)(id response))success
                      failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    
    NSDictionary *dic = @{@"pageIndex":@(killPageIndex),
                          @"pageSize":@(killPageSize)};
    
//        AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:dataURL]];
//    
//        manager.requestSerializer = [AFJSONRequestSerializer serializer];
//        manager.responseSerializer = [AFJSONResponseSerializer serializer];
//    
//        manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
//        manager.securityPolicy.allowInvalidCertificates = YES;
//        manager.securityPolicy.validatesDomainName = NO;
//        [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
//        manager.requestSerializer.timeoutInterval = 20.f;
//        [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
//    
//        //关闭缓存避免干扰测试
//        manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
//    
//    #ifdef ContentType2
//        manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
//    #endif
//        manager.requestSerializer.HTTPShouldHandleCookies = YES;
//        //    manager.requestSerializer.timeoutInterval = 30;
//        manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
//    
//        [manager POST:dataURL parameters:dic
//             progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//                 if (responseObject) {
//                     NSInteger nStatus = [responseObject[@"suc"] integerValue];
//    
//                     if (nStatus == 1) {
//    
//                         NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
//                         NSDictionary *itemData;
//                         NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
//                         
//                         while (itemData = (NSDictionary *)[enumertor nextObject]) {
//                         JKillProducModel *object = [JKillProducModel new];
//                         [object setValuesForKeysWithDictionary:itemData];
//                         [mArrObject addObject:object];
//                             
//                         }
//    
//                         if (success) {
//                             dispatch_async(dispatch_get_main_queue(), ^{
//                                 success(mArrObject);
//                             });
//                         }
//    
//                     }else {
//                         NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
//                         dispatch_async(dispatch_get_main_queue(), ^{
//                             failure(strException);
//                         });
//                     }
//                 }
//             } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//                 NSString *strException = @"网络请求失败";
//                 dispatch_async(dispatch_get_main_queue(), ^{
//                     failure(strException);
//                 });
//             }];
    
    [self requestWihtMethod:RequestMethodTypePost
                        url:dataURL
                 JsonString:dic
                    success:^(id response){
                        
                        if (response) {
                            NSInteger nStatus = [response[@"suc"] integerValue];
                            
                            if (nStatus == 1) {
                                
                                NSEnumerator *enumertor = [response[@"data"] objectEnumerator];
                                NSDictionary *itemData;
                                NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
                                
                                while (itemData = (NSDictionary *)[enumertor nextObject]) {
                                    JKillProducModel *object = [JKillProducModel new];
                                    [object setValuesForKeysWithDictionary:itemData];
                                    [mArrObject addObject:object];
                                    
                                }
                                
                                if (success) {
                                    dispatch_async(dispatch_get_main_queue(), ^{
                                        success(mArrObject);
                                    });
                                }
                                
                            }else {
                                NSString *strException = [NSString stringWithFormat:@"%@", response[@"msg"]];
                                dispatch_async(dispatch_get_main_queue(), ^{
                                    failure(strException);
                                });
                            }
                        }

                    }failure:^(NSError *err){
                        
                        NSString *strException = @"网络请求失败";
                        dispatch_async(dispatch_get_main_queue(), ^{
                            failure(strException);
                        });
                    }];
}

/// 广告图加载
+ (void)LoadAdviceImgUrl:(NSString *)url
                 success:(void (^)(id response))success
                 failure:(void (^)(NSString *err))failure
{
    
    NSString *LoadImgurl = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    
    [self requestWihtMethod:RequestMethodTypePost
                        url:LoadImgurl
                 JsonString:nil
                    success:^(id response){
                        
                        if (response) {
                            NSInteger nStatus = [response[@"suc"] integerValue];
                            
                            if (nStatus == 1) {
                                // 列表数据
                                NSEnumerator *enumertor = [response[@"data"] objectEnumerator];
                                NSDictionary *itemData;
                                NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
                                
                                while (itemData = (NSDictionary *)[enumertor nextObject]) {
                                    JAdviceModel *object = [[JAdviceModel alloc] init];
                                    [object setValuesForKeysWithDictionary:itemData];
                                    [mArrObject addObject:object];
                                }
                                
                                if (success) {
                                    dispatch_async(dispatch_get_main_queue(), ^{
                                        success(mArrObject);
                                    });
                                }
                                
                            }else {
                                NSString *strException = [NSString stringWithFormat:@"%@", response[@"msg"]];
                                dispatch_async(dispatch_get_main_queue(), ^{
                                    failure(strException);
                                });
                            }
                        }
                    }failure:^(NSError *err){
                    
                        NSString *strException = @"网络请求失败";
                        dispatch_async(dispatch_get_main_queue(), ^{
                            failure(strException);
                        });
                    }];
}

/// 分类图加载
+ (void)LoadKindAdviceImgUrl:(NSString *)url
                     success:(void (^)(id response))success
                     failure:(void (^)(NSString *err))failure
{
    NSString *LoadImgurl = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:LoadImgurl]];
    
    //    mgr.securityPolicy = securityPolicy;
//     
    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 20.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
#ifdef ContentType2
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
#endif
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
    //    manager.requestSerializer.timeoutInterval = 30;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
    
    [manager POST:LoadImgurl parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        if (responseObject) {
            NSInteger nStatus = [responseObject[@"suc"] integerValue];
            
            if (nStatus == 1) {
                // 列表数据
                NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
                NSDictionary *itemData;
                NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
                
                while (itemData = (NSDictionary *)[enumertor nextObject]) {
                    JProductTypeModel *object = [[JProductTypeModel alloc] init];
                    [object setValuesForKeysWithDictionary:itemData];
                    [mArrObject addObject:object];
                }
                
                if (success) {
                    dispatch_async(dispatch_get_main_queue(), ^{
                        success(mArrObject);
                    });
                }
                
            }else {
                NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
                dispatch_async(dispatch_get_main_queue(), ^{
                    failure(strException);
                });
            }
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSString *strException = @"网络请求失败";
        dispatch_async(dispatch_get_main_queue(), ^{
            failure(strException);
        });
    }];
    
}

/// 商品列表加载
/// 商品列表加载
+ (void)LoadProductListUrl:(NSString *)url
                 pageModel:(JGetPageModel *)pageModel
                   success:(void (^)(id response))success
                   failure:(void (^)(NSString *err))failure
{
    NSString *LoadImgurl = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    
    NSDictionary *dic = pageModel.mj_keyValues;
    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:LoadImgurl]];
    
    //    mgr.securityPolicy = securityPolicy;
//    dataArray
    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 20.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
#ifdef ContentType2
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
#endif
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
    //    manager.requestSerializer.timeoutInterval = 30;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
    
    [manager POST:LoadImgurl parameters:dic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        if (responseObject) {
            NSInteger nStatus = [responseObject[@"suc"] integerValue];
            
            if (nStatus == 1) {
                // 列表数据
                NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
                NSDictionary *itemData;
                NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
                
                while (itemData = (NSDictionary *)[enumertor nextObject]) {
                    JProductDetailModel *object = [[JProductDetailModel alloc] init];
                    [object setValuesForKeysWithDictionary:itemData];
                    [mArrObject addObject:object];
                }
                
                if (success) {
                    dispatch_async(dispatch_get_main_queue(), ^{
                        success(mArrObject);
                    });
                }
                
            }else {
                NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
                dispatch_async(dispatch_get_main_queue(), ^{
                    failure(strException);
                });
            }
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSString *strException = @"网络请求失败";
        dispatch_async(dispatch_get_main_queue(), ^{
            failure(strException);
        });
    }];
}

/// 当前商品详情加载
+ (void)LoadProductDetailUrl:(NSString *)url
                   pageModel:(JCurrentProductModel *)pageModel
                     success:(void (^)(id response))success
                     failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = @{@"Id":@(pageModel.ProductId),
                          @"CustomerId":@(pageModel.CustomerId)};

    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:dataURL]];
    
    //    mgr.securityPolicy = securityPolicy;
    
    // json 请求
    
    
    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 20.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
#ifdef ContentType2
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
#endif
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
    //    manager.requestSerializer.timeoutInterval = 30;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
    
    [manager POST:dataURL parameters:dic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
                        NSInteger nStatus = [responseObject[@"suc"] integerValue];
                        
                        if (nStatus == 1) {
                            // 列表数据
                            NSDictionary *itemData = responseObject[@"data"];

                            JProductDetailModel *object = [[JProductDetailModel alloc] init];
                            [object setValuesForKeysWithDictionary:itemData];

                            
                            if (success) {
                                dispatch_async(dispatch_get_main_queue(), ^{
                                    success(object);
                                });
                            }
                            
                        }else {
                            NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
                            dispatch_async(dispatch_get_main_queue(), ^{
                                failure(strException);
                            });
                        }
                    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
                        NSString *strException = @"网络请求失败";
                        dispatch_async(dispatch_get_main_queue(), ^{
                            failure(strException);
                        });
                    }];
    
}

/// 当前商品评论加载
+ (void)LoadProductCommentUrl:(NSString *)url
               productIDModel:(JReuqestProductDetailModel *)productIDModel
                      success:(void (^)(id response))success
                      failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = productIDModel.mj_keyValues;
    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:dataURL]];
    
    //    mgr.securityPolicy = securityPolicy;
     
    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 20.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
#ifdef ContentType2
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
#endif
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
    //    manager.requestSerializer.timeoutInterval = 30;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
    
    [manager POST:dataURL
       parameters:dic progress:nil
          success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
              if (responseObject) {
                  NSInteger nStatus = [responseObject[@"suc"] integerValue];
                  
                  if (nStatus == 1) {
                      // 列表数据
                      NSMutableArray  *itemData = responseObject[@"data"];
                      NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
                      if (itemData.count > 0) {
                          // 列表数据
                          NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
                          NSDictionary *itemData;
                          
                          while (itemData = (NSDictionary *)[enumertor nextObject]) {
                              JProductComment *object = [[JProductComment alloc] init];
                              [object setValuesForKeysWithDictionary:itemData];
                              [mArrObject addObject:object];
                          }
                      }
                      
                      if (success) {
                          dispatch_async(dispatch_get_main_queue(), ^{
                              success(mArrObject);
                          });
                      }
                      
                      
                      
                  }else {
                      NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
                      dispatch_async(dispatch_get_main_queue(), ^{
                          failure(strException);
                      });
                  }

              }
          } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
              NSString *strException = @"网络请求失败";
              dispatch_async(dispatch_get_main_queue(), ^{
                  failure(strException);
              });
          }];
}

/// 猜你喜欢加载
+ (void)LoadYouLikeCommentUrl:(NSString *)url
               productIDModel:(JYouLikeModel *)productIDModel
                      success:(void (^)(id response))success
                      failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = productIDModel.mj_keyValues;
    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:dataURL]];
    
    //    mgr.securityPolicy = securityPolicy;
     
    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 20.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
#ifdef ContentType2
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
#endif
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
    //    manager.requestSerializer.timeoutInterval = 30;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
    
    [manager POST:dataURL
       parameters:dic progress:nil
          success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
              if (responseObject) {
                  NSInteger nStatus = [responseObject[@"suc"] integerValue];
                  
                  if (nStatus == 1) {
                      NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
                      NSDictionary *itemData;
                      NSMutableArray *mArrObject = [[NSMutableArray alloc] init];

                      while (itemData = (NSDictionary *)[enumertor nextObject]) {
                          JProductDetailModel *object = [[JProductDetailModel alloc] init];
                          [object setValuesForKeysWithDictionary:itemData];
                          [mArrObject addObject:object];
                      }
                      
                      if (success) {
                          dispatch_async(dispatch_get_main_queue(), ^{
                              success(mArrObject);
                          });
                      }
                      
                      
                  }else {
                      NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
                      dispatch_async(dispatch_get_main_queue(), ^{
                          failure(strException);
                      });
                  }
                  
              }
          } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
              NSString *strException = @"网络请求失败";
              dispatch_async(dispatch_get_main_queue(), ^{
                  failure(strException);
              });
          }];

    
}

/// 加入收藏
+ (void)AddCommentToCollectUrl:(NSString *)url
                productIDModel:(JCurrentProductModel *)productIDModel
                       success:(void (^)(id response))success
                       failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = productIDModel.mj_keyValues;
    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:dataURL]];
    
    //    mgr.securityPolicy = securityPolicy;
     
    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 20.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
#ifdef ContentType2
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
#endif
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
    //    manager.requestSerializer.timeoutInterval = 30;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
    
    [manager POST:dataURL parameters:dic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSInteger nStatus = [responseObject[@"suc"] integerValue];
        
        if (nStatus == 1) {
            // 列表数据
//            NSDictionary *itemData = responseObject[@"data"];
//            
//            JProductDetailModel *object = [[JProductDetailModel alloc] init];
//            [object setValuesForKeysWithDictionary:itemData];
            
            NSInteger num = 1;
            if (success) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    success(@(num));
                });
            }
            
        }else {
            NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
            dispatch_async(dispatch_get_main_queue(), ^{
                failure(strException);
            });
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSString *strException = @"网络请求失败";
        dispatch_async(dispatch_get_main_queue(), ^{
            failure(strException);
        });
    }];
}

/// 搜索
+ (void)SearchProductRequestUrl:(NSString *)url
                           dic :(NSDictionary *)dic
                        success:(void (^)(id response))success
                        failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    
    [self requestWihtMethod:RequestMethodTypePost
                        url:dataURL
                 JsonString:dic
                    success:^(id response) {
                        if (response) {
                            NSInteger nStatus = [response[@"suc"] integerValue];
                            
                            if (nStatus == 1) {
                                NSEnumerator *enumertor = [response[@"data"] objectEnumerator];
                                NSDictionary *itemData;
                                NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
                                
                                while (itemData = (NSDictionary *)[enumertor nextObject]) {
                                    JProductDetailModel *object = [[JProductDetailModel alloc] init];
                                    [object setValuesForKeysWithDictionary:itemData];
                                    [mArrObject addObject:object];
                                }
                                
                                if (success) {
                                    dispatch_async(dispatch_get_main_queue(), ^{
                                        success(mArrObject);
                                    });
                                }
                                
                                
                            }else {
                                NSString *strException = [NSString stringWithFormat:@"%@", response[@"msg"]];
                                dispatch_async(dispatch_get_main_queue(), ^{
                                    failure(strException);
                                });
                            }
                        }
                    } failure:^(NSError *err) {
                        NSString *strException = @"网络请求失败";
                        dispatch_async(dispatch_get_main_queue(), ^{
                            failure(strException);
                        });
                    }];
}

//Categories/GetCategoriesByParentId
/// 商品类型二级页面
+ (void)getProductSecondRequestUrl:(NSString *)url
                  productTypeModel:(JProductTypeModel *)typeModel
                           success:(void (^)(id response))success
                           failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = @{@"CategoryId":@(typeModel.Id),
                          @"CustomerId":@([GLOBALDATA userInfoModel].CustomerId),
                          @"UserId":@([GLOBALDATA userInfoModel].Id)};
    
    [self requestWihtMethod:RequestMethodTypePost
                        url:dataURL
                 JsonString:dic
                    success:^(id response) {
                        if (response) {
                            NSInteger nStatus = [response[@"suc"] integerValue];
                            
                            if (nStatus == 1) {
                                NSEnumerator *enumertor = [response[@"data"] objectEnumerator];
                                NSDictionary *itemData;
                                NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
                                
                                while (itemData = (NSDictionary *)[enumertor nextObject]) {
                                    JProductTypeModel *object = [[JProductTypeModel alloc] init];
                                    [object setValuesForKeysWithDictionary:itemData];
                                    [mArrObject addObject:object];
                                }
                                
                                if (success) {
                                    dispatch_async(dispatch_get_main_queue(), ^{
                                        success(mArrObject);
                                    });
                                }
                                
                                
                            }else {
                                NSString *strException = [NSString stringWithFormat:@"%@", response[@"msg"]];
                                dispatch_async(dispatch_get_main_queue(), ^{
                                    failure(strException);
                                });
                            }
                        }
                    } failure:^(NSError *err) {
                        NSString *strException = @"网络请求失败";
                        dispatch_async(dispatch_get_main_queue(), ^{
                            failure(strException);
                        });
                    }];
}

//Products/GetProducts
/// 商品类型二级页面 Product
+ (void)getProductListRequestUrl:(NSString *)url
                  productListDic:(NSDictionary *)productListDic
                         success:(void (^)(id response))success
                         failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
//    NSDictionary *dic = @{@"CategoryId":@(typeModel.Id),
//                          @"CustomerId":@([GLOBALDATA userInfoModel].CustomerId),
//                          @"UserId":@([GLOBALDATA userInfoModel].Id)};
    
    [self requestWihtMethod:RequestMethodTypePost
                        url:dataURL
                 JsonString:productListDic
                    success:^(id response) {
                        if (response) {
                            NSInteger nStatus = [response[@"suc"] integerValue];
                            
                            if (nStatus == 1) {
                                NSEnumerator *enumertor = [response[@"data"] objectEnumerator];
                                NSDictionary *itemData;
                                NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
                                
                                while (itemData = (NSDictionary *)[enumertor nextObject]) {
                                    JProductDetailModel *object = [[JProductDetailModel alloc] init];
                                    [object setValuesForKeysWithDictionary:itemData];
                                    [mArrObject addObject:object];
                                }
                                
                                if (success) {
                                    dispatch_async(dispatch_get_main_queue(), ^{
                                        success(mArrObject);
                                    });
                                }
                                
                                
                            }else {
                                NSString *strException = [NSString stringWithFormat:@"%@", response[@"msg"]];
                                dispatch_async(dispatch_get_main_queue(), ^{
                                    failure(strException);
                                });
                            }
                        }
                    } failure:^(NSError *err) {
                        NSString *strException = @"网络请求失败";
                        dispatch_async(dispatch_get_main_queue(), ^{
                            failure(strException);
                        });
                    }];
}

/// 请求产品属性 ，加入购物车
+ (void)GetProductAttributeUrl:(NSString *)url
                productIDModel:(JCurrentProductModel *)productIDModel
                       success:(void (^)(id response))success
                       failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = @{@"Id":@(productIDModel.ProductId)};
    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:dataURL]];
    
    //    mgr.securityPolicy = securityPolicy;
     
    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 20.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
#ifdef ContentType2
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
#endif
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
    //    manager.requestSerializer.timeoutInterval = 30;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
    
    [manager POST:dataURL parameters:dic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSInteger nStatus = [responseObject[@"suc"] integerValue];
        
        if (nStatus == 1) {
            NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
            NSDictionary *itemData;
            NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
            
            while (itemData = (NSDictionary *)[enumertor nextObject]) {
                JProductAttributeModel *object = [[JProductAttributeModel alloc] init];
                [object setValuesForKeysWithDictionary:itemData];
                [mArrObject addObject:object];
            }
            if (success) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    success(mArrObject);
                });
            }
            
        }else {
            NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
            dispatch_async(dispatch_get_main_queue(), ^{
                failure(strException);
            });
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSString *strException = @"网络请求失败";
        dispatch_async(dispatch_get_main_queue(), ^{
            failure(strException);
        });
    }];
}

/// 商品添加购物车，或购买
+ (void)GetProductAttributeUrl:(NSString *)url
               buyProductModel:(JAddToShopCarRequestModel *)buyProductModel
                       success:(void (^)(id response))success
                       failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = buyProductModel.mj_keyValues;
    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:dataURL]];
    
    //    mgr.securityPolicy = securityPolicy;
     
    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 20.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
#ifdef ContentType2
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
#endif
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
    //    manager.requestSerializer.timeoutInterval = 30;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
    
    [manager POST:dataURL parameters:dic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSInteger nStatus = [responseObject[@"suc"] integerValue];
        
        if (nStatus == 1) {
//            NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
//            NSDictionary *itemData;
//            NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
//            
//            while (itemData = (NSDictionary *)[enumertor nextObject]) {
//                JProductAttributeModel *object = [[JProductAttributeModel alloc] init];
//                [object setValuesForKeysWithDictionary:itemData];
//                [mArrObject addObject:object];
//            }
            if (success) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    success(@1);
                });
            }
            
        }else {
            NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
            dispatch_async(dispatch_get_main_queue(), ^{
                failure(strException);
            });
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSString *strException = @"网络请求失败";
        dispatch_async(dispatch_get_main_queue(), ^{
            failure(strException);
        });
    }];
}

/// 获取购物车列表
+ (void)GetShopCarProductListUrl:(NSString *)url
                      productIDs:(NSString *)productIDs
                          userID:(JUserInfoModel *)userInfo
                         success:(void (^)(id response))success
                         failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic;
    if (productIDs) {
        dic = @{@"CustomerId":@(userInfo.CustomerId),
                @"UserId":@(userInfo.CustomerId),
                @"Ids":productIDs};
    }
    else
    {
        dic = @{@"CustomerId":@(userInfo.CustomerId),
                @"UserId":@(userInfo.CustomerId)
                };
    }

    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:dataURL]];
    
    //    mgr.securityPolicy = securityPolicy;
     
    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 20.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
#ifdef ContentType2
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
#endif
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
    //    manager.requestSerializer.timeoutInterval = 30;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
    
    [manager POST:dataURL parameters:dic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSInteger nStatus = [responseObject[@"suc"] integerValue];
        
        if (nStatus == 1) {
            NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
            NSDictionary *itemData;
            NSMutableArray *mArrObject = [[NSMutableArray alloc] init];

            while (itemData = (NSDictionary *)[enumertor nextObject]) {
                JShopCarShopModel *object = [[JShopCarShopModel alloc] init];
                [object setValuesForKeysWithDictionary:itemData];
                [mArrObject addObject:object];
            }
            
            if (success) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    success(mArrObject);
                });
            }
            
        }else {
            NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
            dispatch_async(dispatch_get_main_queue(), ^{
                failure(strException);
            });
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSString *strException = @"网络请求失败";
        dispatch_async(dispatch_get_main_queue(), ^{
            failure(strException);
        });
    }];
}

/// 更改购物车商品数量
+ (void)UpdateShopCarProductListUrl:(NSString *)url
                         productArr:(NSArray *)productMArr
                            success:(void (^)(id response))success
                            failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
//    NSDictionary *dic = @{@"CustomerId":@(userInfo.CustomerId),
//                          @"UserId":@(userInfo.CustomerId)};
    
    
    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:dataURL]];
    
//        manager.securityPolicy = securityPolicy;
    
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    
    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 20.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
#ifdef ContentType2
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
#endif
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
    //    manager.requestSerializer.timeoutInterval = 30;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
    
    [manager POST:dataURL parameters:productMArr progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSInteger nStatus = [responseObject[@"suc"] integerValue];
        
        if (nStatus == 1) {
//            NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
//            NSDictionary *itemData;
//            NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
//            
//            while (itemData = (NSDictionary *)[enumertor nextObject]) {
//                JShopCarShopModel *object = [[JShopCarShopModel alloc] init];
//                [object setValuesForKeysWithDictionary:itemData];
//                [object setValueForDetailModelDic];
//                [mArrObject addObject:object];
//            }
            
            if (success) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    success(@1);
                });
            }
            
        }else {
            NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
            dispatch_async(dispatch_get_main_queue(), ^{
                failure(strException);
            });
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSString *strException = @"网络请求失败";
        dispatch_async(dispatch_get_main_queue(), ^{
            failure(strException);
        });
    }];
}

//ShoppingCartItems/DeleteShoppingCartItem
///  购物车   删除商品
+ (void)DelectShopCarProductUrl:(NSString *)url
                      productID:(NSInteger)productID
                        success:(void (^)(id response))success
                        failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = @{@"Id":@(productID)};

    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:dataURL]];
    
    
    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 20.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
#ifdef ContentType2
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
#endif
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
    //    manager.requestSerializer.timeoutInterval = 30;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
    
    [manager POST:dataURL parameters:dic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSInteger nStatus = [responseObject[@"suc"] integerValue];
        
        if (nStatus == 1) {
            //            NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
            //            NSDictionary *itemData;
            //            NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
            //
            //            while (itemData = (NSDictionary *)[enumertor nextObject]) {
            //                JShopCarShopModel *object = [[JShopCarShopModel alloc] init];
            //                [object setValuesForKeysWithDictionary:itemData];
            //                [object setValueForDetailModelDic];
            //                [mArrObject addObject:object];
            //            }
            
            if (success) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    success(@1);
                });
            }
            
        }else {
            NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
            dispatch_async(dispatch_get_main_queue(), ^{
                failure(strException);
            });
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSString *strException = @"网络请求失败";
        dispatch_async(dispatch_get_main_queue(), ^{
            failure(strException);
        });
    }];
}
//Address/GetAddress
///  用户地址
+ (void)CustomerAddressRequestUrl:(NSString *)url
                       CustumerID:(NSInteger)CustumerID
                          success:(void (^)(id response))success
                          failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = @{@"CustomerId":@(CustumerID)};
    
    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:dataURL]];
    
    
    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 20.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
#ifdef ContentType2
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
#endif
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
    //    manager.requestSerializer.timeoutInterval = 30;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
    
    [manager POST:dataURL parameters:dic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSInteger nStatus = [responseObject[@"suc"] integerValue];
        
        if (nStatus == 1) {
          
            //            NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
            //            NSDictionary *itemData;
            //            NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
            //
            //            while (itemData = (NSDictionary *)[enumertor nextObject]) {
            //                JShopCarShopModel *object = [[JShopCarShopModel alloc] init];
            //                [object setValuesForKeysWithDictionary:itemData];
            //                [object setValueForDetailModelDic];
            //                [mArrObject addObject:object];
            //            }
            
            if (success) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    success(responseObject[@"data"]);
                });
            }
            
        }else {
            NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
            dispatch_async(dispatch_get_main_queue(), ^{
                failure(strException);
            });
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSString *strException = @"网络请求失败";
        dispatch_async(dispatch_get_main_queue(), ^{
            failure(strException);
        });
    }];
}

//Address/GetAddressForCustomer
///  获取用户收货地址列表
+ (void)getCustomerAddressListRequestUrl:(NSString *)url
                                 success:(void (^)(id response))success
                                 failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = @{@"CustomerId":@([GLOBALDATA userInfoModel].CustomerId)};
    
    [self requestWihtMethod:RequestMethodTypePost
                        url:dataURL
                 JsonString:dic
                    success:^(id response) {
                        NSInteger nStatus = [response[@"suc"] integerValue];
                        
                        if (nStatus == 1) {
                            
                            NSEnumerator *enumertor = [response[@"data"] objectEnumerator];
                            NSDictionary *itemData;
                            NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
                
                            while (itemData = (NSDictionary *)[enumertor nextObject]) {
                                JAddressModel *object = [[JAddressModel alloc] init];
                                [object setValuesForKeysWithDictionary:itemData];
                                [mArrObject addObject:object];
                            }
                            
                            if (success) {
                                dispatch_async(dispatch_get_main_queue(), ^{
                                    success(mArrObject);
                                });
                            }
                            
                        }else {
                            NSString *strException = [NSString stringWithFormat:@"%@", response[@"msg"]];
                            dispatch_async(dispatch_get_main_queue(), ^{
                                failure(strException);
                            });
                        }
                    } failure:^(NSError *err) {
                        NSString *strException = @"网络请求失败";
                        dispatch_async(dispatch_get_main_queue(), ^{
                            failure(strException);
                        });
                    }];
}

//Address/GetAreaJsonData
///  获取省市区 详情
+ (void)AddressCityInfoRequestUrl:(NSString *)url
                          success:(void (^)(id response))success
                          failure:(void (^)(NSString *err))failure
{
    NSString *requestUrl = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    
    [self requestWihtMethod:RequestMethodTypePost
                        url:requestUrl
                 JsonString:nil
                    success:^(id response) {
                        NSInteger nStatus = [response[@"suc"] integerValue];

                        if (nStatus == 1) {
                            
                            NSData *data = [response[@"data"] dataUsingEncoding:NSUTF8StringEncoding];
                            
                            NSArray *arr = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
                            
                            NSMutableArray *mArrObject = [[NSMutableArray alloc] init];

                            for (NSDictionary *dic in arr) {
                                JAddressProvinceModel *model = [JAddressProvinceModel new];
                                [model setValuesForKeysWithDictionary:dic];
                                [mArrObject addObject:model];
                            }
                            
                            if (success) {
                                dispatch_async(dispatch_get_main_queue(), ^{
                                    success(mArrObject);
                                });
                            }
                        }
                        else
                        {
                            NSString *strException = response[@"msg"];
                            dispatch_async(dispatch_get_main_queue(), ^{
                                failure(strException);
                            });
                        }
                        
                    } failure:^(NSError *err) {
                        NSString *strException = @"网络请求失败";
                        dispatch_async(dispatch_get_main_queue(), ^{
                            failure(strException);
                        });
                    }];
}

//Address/CreateAddress
///  添加收货地址
+ (void)AddCustomerAddressRequestUrl:(NSString *)url
                     addAddressModel:(JAddressAddModel *)addAddressModel
                             success:(void (^)(id response))success
                             failure:(void (^)(NSString *err))failure
{
    NSString *requestUrl = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = addAddressModel.mj_keyValues;
    
    [self requestWihtMethod:RequestMethodTypePost
                        url:requestUrl
                 JsonString:dic
                    success:^(id response) {
                        NSInteger nStatus = [response[@"suc"] integerValue];
                        
                        if (nStatus == 1) {
                            
//                            NSEnumerator *enumertor = [response[@"data"] objectEnumerator];
//                            NSDictionary *itemData;
//                            NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
//                
//                            while (itemData = (NSDictionary *)[enumertor nextObject]) {
//                                JShopCarShopModel *object = [[JShopCarShopModel alloc] init];
//                                [object setValuesForKeysWithDictionary:itemData];
//                                [object setValueForDetailModelDic];
//                                [mArrObject addObject:object];
//                            }
                            
                            if (success) {
                                dispatch_async(dispatch_get_main_queue(), ^{
                                    success(@1);
                                });
                            }
                        }
                        else
                        {
                            NSString *strException = response[@"msg"];
                            dispatch_async(dispatch_get_main_queue(), ^{
                                failure(strException);
                            });
                        }
                        
                    } failure:^(NSError *err) {
                        NSString *strException = @"网络请求失败";
                        dispatch_async(dispatch_get_main_queue(), ^{
                            failure(strException);
                        });
                    }];
}

//Address/SetDefaultAddress
///  更新默认收货地址
+ (void)SetDefaultAddressRequestUrl:(NSString *)url
                       AddressModel:(JAddressModel *)AddressModel
                            success:(void (^)(id response))success
                            failure:(void (^)(NSString *err))failure
{
    NSString *requestUrl = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = @{@"CustomerId":@([GLOBALDATA userInfoModel].CustomerId),
                          @"Id":@(AddressModel.Id)};
    
    [self requestWihtMethod:RequestMethodTypePost
                        url:requestUrl
                 JsonString:dic
                    success:^(id response) {
                        NSInteger nStatus = [response[@"suc"] integerValue];
                        
                        if (nStatus == 1) {
                            
                            //                            NSEnumerator *enumertor = [response[@"data"] objectEnumerator];
                            //                            NSDictionary *itemData;
                            //                            NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
                            //
                            //                            while (itemData = (NSDictionary *)[enumertor nextObject]) {
                            //                                JShopCarShopModel *object = [[JShopCarShopModel alloc] init];
                            //                                [object setValuesForKeysWithDictionary:itemData];
                            //                                [object setValueForDetailModelDic];
                            //                                [mArrObject addObject:object];
                            //                            }
                            
                            if (success) {
                                dispatch_async(dispatch_get_main_queue(), ^{
                                    success(@1);
                                });
                            }
                        }
                        else
                        {
                            NSString *strException = response[@"msg"];
                            dispatch_async(dispatch_get_main_queue(), ^{
                                failure(strException);
                            });
                        }
                        
                    } failure:^(NSError *err) {
                        NSString *strException = @"网络请求失败";
                        dispatch_async(dispatch_get_main_queue(), ^{
                            failure(strException);
                        });
                    }];
}

//Address/DeleteAddress
///  删除收货地址
+ (void)DeleteAddressRequestUrl:(NSString *)url
                   AddressModel:(JAddressModel *)AddressModel
                        success:(void (^)(id response))success
                        failure:(void (^)(NSString *err))failure
{
    NSString *requestUrl = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = @{@"Id":@(AddressModel.Id)};
    
    [self requestWihtMethod:RequestMethodTypePost
                        url:requestUrl
                 JsonString:dic
                    success:^(id response) {
                        NSInteger nStatus = [response[@"suc"] integerValue];
                        
                        if (nStatus == 1) {
                            
                            //                            NSEnumerator *enumertor = [response[@"data"] objectEnumerator];
                            //                            NSDictionary *itemData;
                            //                            NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
                            //
                            //                            while (itemData = (NSDictionary *)[enumertor nextObject]) {
                            //                                JShopCarShopModel *object = [[JShopCarShopModel alloc] init];
                            //                                [object setValuesForKeysWithDictionary:itemData];
                            //                                [object setValueForDetailModelDic];
                            //                                [mArrObject addObject:object];
                            //                            }
                            
                            if (success) {
                                dispatch_async(dispatch_get_main_queue(), ^{
                                    success(@1);
                                });
                            }
                        }
                        else
                        {
                            NSString *strException = response[@"msg"];
                            dispatch_async(dispatch_get_main_queue(), ^{
                                failure(strException);
                            });
                        }
                        
                    } failure:^(NSError *err) {
                        NSString *strException = @"网络请求失败";
                        dispatch_async(dispatch_get_main_queue(), ^{
                            failure(strException);
                        });
                    }];
}

//Address/GetAddress
///  支付页面默认地址
+ (void)getAddressRequestUrl:(NSString *)url
                       CustumerID:(NSInteger)CustumerID
                          success:(void (^)(id response))success
                          failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = @{@"CustomerId":@(CustumerID),
                          @"Id":@(0),
                          @"UserId":@(CustumerID)};
    
    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:dataURL]];
    
    
    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 20.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
#ifdef ContentType2
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
#endif
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
    //    manager.requestSerializer.timeoutInterval = 30;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
    
    [manager POST:dataURL parameters:dic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSInteger nStatus = [responseObject[@"suc"] integerValue];
        
        if (nStatus == 1) {
            
//            NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
            NSDictionary *itemData = responseObject[@"data"];
//            NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
//
//            while (itemData = (NSDictionary *)[enumertor nextObject]) {
                JAddressModel *object = [JAddressModel new];
                [object setValuesForKeysWithDictionary:itemData];
//                [mArrObject addObject:object];
//            }
            
            if (success) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    success(object);
                });
            }
            
        }else {
            NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
            dispatch_async(dispatch_get_main_queue(), ^{
                failure(strException);
            });
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSString *strException = @"网络请求失败";
        dispatch_async(dispatch_get_main_queue(), ^{
            failure(strException);
        });
    }];
}

// WeChart / GetOpenId
///  获取用户微信信息
+ (void)getUserWXInfoRequestUrl:(NSString *)url
                         code:(NSString *)code
                      success:(void (^)(id response))success
                      failure:(void (^)(NSString *err))failure
{
    NSString *urlda = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = @{@"Code":code,
                          @"ClientType":@(2)};
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    
    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 20.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
#ifdef ContentType2
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
#endif
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
    //    manager.requestSerializer.timeoutInterval = 30;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
    
    [manager POST:urlda parameters:dic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSInteger nStatus = [responseObject[@"suc"] integerValue];
        
        if (nStatus == 1) {
            
            if (success) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    success(responseObject[@"data"]);
                });
            }
            
        }else {
            NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
            dispatch_async(dispatch_get_main_queue(), ^{
                failure(strException);
            });
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSString *strException = @"网络请求失败";
        dispatch_async(dispatch_get_main_queue(), ^{
            failure(strException);
        });
    }];
}

//Customers/GetCustomerById
///  获取用户信息
+ (void)getUserInfoRequestUrl:(NSString *)url
                   CustumerID:(NSInteger)CustumerID
                      success:(void (^)(id response))success
                      failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = @{@"CustomerId":@(CustumerID),
                          @"UserId":@(CustumerID)};
    
    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:dataURL]];
    
    
    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 20.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
#ifdef ContentType2
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
#endif
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
    //    manager.requestSerializer.timeoutInterval = 30;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
    
    [manager POST:dataURL parameters:dic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSInteger nStatus = [responseObject[@"suc"] integerValue];
        
        if (nStatus == 1) {
            
            //            NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
            NSDictionary *itemData = responseObject[@"data"];
            //            NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
            //
            //            while (itemData = (NSDictionary *)[enumertor nextObject]) {
            JUserInfoModel *object = [JUserInfoModel new];
            [object setValuesForKeysWithDictionary:itemData];
            object.CustomerId = object.Id;
            //                [mArrObject addObject:object];
            //            }
            
            [GLOBALDATA setUserInfoModel:object];

            
            if (success) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    success(object);
                });
            }
            
        }else {
            NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
            dispatch_async(dispatch_get_main_queue(), ^{
                failure(strException);
            });
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSString *strException = @"网络请求失败";
        dispatch_async(dispatch_get_main_queue(), ^{
            failure(strException);
        });
    }];
}

//Orders/GetOrdersCount
///  获取用户账单信息
+ (void)getUserOrderInfoRequestUrl:(NSString *)url
                        CustumerID:(NSInteger)CustumerID
                           success:(void (^)(id response))success
                           failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = @{@"CustomerId":@(CustumerID),
                          @"UserId":@(CustumerID)};
    
    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:dataURL]];
    
    
    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 20.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
#ifdef ContentType2
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
#endif
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
    //    manager.requestSerializer.timeoutInterval = 30;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
    
    [manager POST:dataURL parameters:dic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSInteger nStatus = [responseObject[@"suc"] integerValue];
        
        if (nStatus == 1) {
            
            //            NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
            NSDictionary *itemData = responseObject[@"data"];
            //            NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
            //
            //            while (itemData = (NSDictionary *)[enumertor nextObject]) {
            JMyAllOrderNumModel *object = [JMyAllOrderNumModel new];
            [object setValuesForKeysWithDictionary:itemData];
            //                [mArrObject addObject:object];
            //            }
            
            if (success) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    success(object);
                });
            }
            
        }else {
            NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
            dispatch_async(dispatch_get_main_queue(), ^{
                failure(strException);
            });
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSString *strException = @"网络请求失败";
        dispatch_async(dispatch_get_main_queue(), ^{
            failure(strException);
        });
    }];
}

//Orders/GetOrdersByCustomerId
///  获取用户待付款账单信息
+ (void)getUserWaitPayOrderInfoUrl:(NSString *)url
                            typeID:(NSInteger)type
                           success:(void (^)(id response))success
                           failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = @{@"CustomerId":@([GLOBALDATA userInfoModel].CustomerId),
                          @"UserId":@([GLOBALDATA userInfoModel].CustomerId),
                          @"Type":@(type)};
    
    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:dataURL]];
    
    
    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 20.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
#ifdef ContentType2
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
#endif
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
    //    manager.requestSerializer.timeoutInterval = 30;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
    
    [manager POST:dataURL parameters:dic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSInteger nStatus = [responseObject[@"suc"] integerValue];
        
        if (nStatus == 1) {
            
            NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
            NSDictionary *itemData ;
            NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
            
            while (itemData = (NSDictionary *)[enumertor nextObject]) {
                JWaitPayModel *object = [JWaitPayModel new];
                [object setValuesForKeysWithDictionary:itemData];
                [mArrObject addObject:object];
            }
            
            if (success) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    success(mArrObject);
                });
            }
            
        }else {
            NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
            dispatch_async(dispatch_get_main_queue(), ^{
                failure(strException);
            });
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSString *strException = @"网络请求失败";
        dispatch_async(dispatch_get_main_queue(), ^{
            failure(strException);
        });
    }];
}

//ServerOrder/GetServerOrders
///  获取用户待付款账单信息（团购）
+ (void)getGroupUserWaitPayOrderInfoUrl:(NSString *)url
                                 typeID:(NSInteger)type
                                success:(void (^)(id response))success
                                failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = @{@"CustomerId":@([GLOBALDATA userInfoModel].CustomerId),
                          @"CreateBy":@([GLOBALDATA userInfoModel].CustomerId),
                          @"UserId":@([GLOBALDATA userInfoModel].CustomerId),
                          @"ServerOrderStatus":@(type)};
    
    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:dataURL]];
    
    
    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 20.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
#ifdef ContentType2
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
#endif
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
    //    manager.requestSerializer.timeoutInterval = 30;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
    
    [manager POST:dataURL parameters:dic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSInteger nStatus = [responseObject[@"suc"] integerValue];
        
        if (nStatus == 1) {
            
            NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
            NSDictionary *itemData ;
            NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
            
            while (itemData = (NSDictionary *)[enumertor nextObject]) {
                JOrderGroupModel *object = [JOrderGroupModel new];
                [object setValuesForKeysWithDictionary:itemData];
                [mArrObject addObject:object];
            }
            
            if (success) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    success(mArrObject);
                });
            }
            
        }else {
            NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
            dispatch_async(dispatch_get_main_queue(), ^{
                failure(strException);
            });
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSString *strException = @"网络请求失败";
        dispatch_async(dispatch_get_main_queue(), ^{
            failure(strException);
        });
    }];
}

//Orders/CancelOrder
///  取消订单
+ (void)cancelOrderRequedtUrl:(NSString *)url
                 waitPatModel:(id)paymodel
                      success:(void (^)(id response))success
                      failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic;
    if ([paymodel isKindOfClass:[JWaitPayModel class]]) {
        JWaitPayModel *model = paymodel;
        dic = @{@"Id":@(model.OrderId),
                @"OrderStatusId":@(model.OrderStatusId)};
    }
    else
    {
        JOrderGroupModel *model = paymodel;

        dic = @{@"CreateBy":@(model.CreateBy),
                @"CustomerId":@([GLOBALDATA userInfoModel].CustomerId),
                @"Id":@(model.Id),
                @"UserId":@([GLOBALDATA userInfoModel].CustomerId)};
    }
    
    [self requestWihtMethod:RequestMethodTypePost
                        url:dataURL
                 JsonString:dic
                    success:^(id response) {
                        NSInteger nStatus = [response[@"suc"] integerValue];
                        if (nStatus == 1) {
                            if (success) {
                                dispatch_async(dispatch_get_main_queue(), ^{
                                    success(@1);
                                });
                            }
                        }else {
                            NSString *strException = [NSString stringWithFormat:@"%@", response[@"msg"]];
                            dispatch_async(dispatch_get_main_queue(), ^{
                                failure(strException);
                            });
                        }
                    } failure:^(NSError *err) {
                        NSString *strException = @"网络请求失败";
                        dispatch_async(dispatch_get_main_queue(), ^{
                            failure(strException);
                        });
                    }];
}


// Orders/ReturnOrderItem 待发货状态时的接口
// Orders/CreateReturnOrder 待收货状态时的接口
///  退货
+ (void)ReturnOrderRequedtUrl:(NSString *)url
                 waitPatModel:(NSDictionary  *)dic
                      success:(void (^)(id response))success
                      failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    
    
    [self requestWihtMethod:RequestMethodTypePost
                        url:dataURL
                 JsonString:dic
                    success:^(id response) {
                        NSInteger nStatus = [response[@"suc"] integerValue];
                        if (nStatus == 1) {
                            if (success) {
                                dispatch_async(dispatch_get_main_queue(), ^{
                                    success(@1);
                                });
                            }
                        }else {
                            NSString *strException = [NSString stringWithFormat:@"%@", response[@"msg"]];
                            dispatch_async(dispatch_get_main_queue(), ^{
                                failure(strException);
                            });
                        }
                    } failure:^(NSError *err) {
                        NSString *strException = @"网络请求失败";
                        dispatch_async(dispatch_get_main_queue(), ^{
                            failure(strException);
                        });
                    }];
}

//Customers/UpdateCustomer
///  更新用户信息
+ (void)UpdateCustomerInfoRequedtUrl:(NSString *)url
                         userInfoObj:(JUserInfoModel *)userInfoObj
                             success:(void (^)(id response))success
                             failure:(void (^)(NSString *err))failure
{
    
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = @{@"Id":@(userInfoObj.Id),
                          @"Username":userInfoObj.Username,
                          @"Tel":userInfoObj.Tel,
                          @"Email":userInfoObj.Email};
    
    [self requestWihtMethod:RequestMethodTypePost
                        url:dataURL
                 JsonString:dic
                    success:^(id response) {
                        NSInteger nStatus = [response[@"suc"] integerValue];
                        if (nStatus == 1) {
                            if (success) {
                                dispatch_async(dispatch_get_main_queue(), ^{
                                    success(@1);
                                });
                            }
                        }else {
                            NSString *strException = [NSString stringWithFormat:@"%@", response[@"msg"]];
                            dispatch_async(dispatch_get_main_queue(), ^{
                                failure(strException);
                            });
                        }
                    } failure:^(NSError *err) {
                        NSString *strException = @"网络请求失败";
                        dispatch_async(dispatch_get_main_queue(), ^{
                            failure(strException);
                        });
                    }];
}

//BusinessSettled/SendMobileMsg
///  商家入驻
+ (void)BusinessSettledRequedtUrl:(NSString *)url
                          success:(void (^)(id response))success
                          failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = @{@"CreateBy":@([GLOBALDATA userInfoModel].CustomerId)};
    
    [self requestWihtMethod:RequestMethodTypePost
                        url:dataURL
                 JsonString:dic
                    success:^(id response) {
                        NSInteger nStatus = [response[@"suc"] integerValue];
                        if (nStatus == 1) {
                            NSString *successStr = @"商家入驻地址以短信的方式发送给您，请收到短信后在PC端进行入驻申请！";
                            if (success) {
                                dispatch_async(dispatch_get_main_queue(), ^{
                                    success(successStr);
                                });
                            }
                        }
                        else {
                            NSString *successStr = @"发送短信失败，请确认您的电话号码是否正确！";
//                            NSString *strException = [NSString stringWithFormat:@"%@", response[@"msg"]];
                            dispatch_async(dispatch_get_main_queue(), ^{
                                failure(successStr);
                            });
                        }
                    } failure:^(NSError *err) {
                        NSString *strException = @"网络请求失败";
                        dispatch_async(dispatch_get_main_queue(), ^{
                            failure(strException);
                        });
                    }];
}

//FeadBack/InsertFeadback
///  意见反馈
+ (void)FeedBackRequedtUrl:(NSString *)url
                   Content:(NSDictionary *)ContentDic
                   success:(void (^)(id response))success
                   failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = ContentDic;
    
    [self requestWihtMethod:RequestMethodTypePost
                        url:dataURL
                 JsonString:dic
                    success:^(id response) {
                        NSInteger nStatus = [response[@"suc"] integerValue];
                        if (nStatus == 1) {
                            
                            if (success) {
                                dispatch_async(dispatch_get_main_queue(), ^{
                                    success(@1);
                                });
                            }
                        }
                        else {
                        NSString *strException = [NSString stringWithFormat:@"%@", response[@"msg"]];
                            dispatch_async(dispatch_get_main_queue(), ^{
                                failure(strException);
                            });
                        }
                    } failure:^(NSError *err) {
                        NSString *strException = @"网络请求失败";
                        dispatch_async(dispatch_get_main_queue(), ^{
                            failure(strException);
                        });
                    }];
}

#define mark - collect Request

//Products/GetFavoriteProducts
///  收藏商品
+ (void)getCollectProductRequedtUrl:(NSString *)url
                            success:(void (^)(id response))success
                            failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = @{@"CustomerId":@([GLOBALDATA userInfoModel].CustomerId)};
    
    [self requestWihtMethod:RequestMethodTypePost
                        url:dataURL
                 JsonString:dic
                    success:^(id response) {
                        NSInteger nStatus = [response[@"suc"] integerValue];
                        if (nStatus == 1) {
                            // 列表数据
                            NSEnumerator *enumertor = [response[@"data"] objectEnumerator];
                            NSDictionary *itemData;
                            NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
                            
                            while (itemData = (NSDictionary *)[enumertor nextObject]) {
                                JProductDetailModel *object = [[JProductDetailModel alloc] init];
                                [object setValuesForKeysWithDictionary:itemData];
                                [mArrObject addObject:object];
                            }
                            
                            if (success) {
                                dispatch_async(dispatch_get_main_queue(), ^{
                                    success(mArrObject);
                                });
                            }
                        }
                        else {
                            NSString *strException = [NSString stringWithFormat:@"%@", response[@"msg"]];
                            dispatch_async(dispatch_get_main_queue(), ^{
                                failure(strException);
                            });
                        }
                    } failure:^(NSError *err) {
                        NSString *strException = @"网络请求失败";
                        dispatch_async(dispatch_get_main_queue(), ^{
                            failure(strException);
                        });
                    }];
}

//Vendor/GetCollectVendors
///  收藏店铺
+ (void)getCollectShopRequedtUrl:(NSString *)url
                         success:(void (^)(id response))success
                         failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = @{@"CustomerId":@([GLOBALDATA userInfoModel].CustomerId)};
    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:dataURL]];
    
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    
    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 20.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
#ifdef ContentType2
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
#endif
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
    //    manager.requestSerializer.timeoutInterval = 30;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
    
    [manager POST:dataURL
       parameters:dic
         progress:nil
          success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
              if (responseObject) {
                  NSInteger nStatus = [responseObject[@"suc"] integerValue];
                  if (nStatus == 1) {
                      // 列表数据
                      NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
                      NSDictionary *itemData;
                      NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
                      
                      while (itemData = (NSDictionary *)[enumertor nextObject]) {
                          JVendorModel *object = [[JVendorModel alloc] init];
                          [object setValuesForKeysWithDictionary:itemData];
                          [mArrObject addObject:object];
                      }
                      
                      if (success) {
                          dispatch_async(dispatch_get_main_queue(), ^{
                              success(mArrObject);
                          });
                      }
                  }
                  else {
                      NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
                      dispatch_async(dispatch_get_main_queue(), ^{
                          failure(strException);
                      });
                  }
              }
          } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
              NSString *strException = @"网络请求失败";
              dispatch_async(dispatch_get_main_queue(), ^{
                  failure(strException);
              });
          }];
    
}


#define mark - Comment
//Products/ProductComment
///  发布评论
+ (void)submitProductCommentRequedtUrl:(NSString *)url
                         parpemDic:(NSDictionary *)parpemDic
                               success:(void (^)(id response))success
                               failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = parpemDic;
    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:dataURL]];
    
    

    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 30.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
    
    //申明请求的数据是json类型
    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
    
    //申明返回的结果是json类型
    manager.responseSerializer = [AFJSONResponseSerializer serializer];
    
    //如果报接受类型不一致请替换一致text/html或别的
//    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", nil];
    
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", @"text/plain",nil];
    
    [manager POST:dataURL
       parameters:dic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
           NSInteger nStatus = [responseObject[@"suc"] integerValue];
           if (nStatus == 1) {
               // 列表数据
               //                            NSEnumerator *enumertor = [response[@"data"] objectEnumerator];
               //                            NSDictionary *itemData;
               //                            NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
               //
               //                            while (itemData = (NSDictionary *)[enumertor nextObject]) {
               //                                JProductDetailModel *object = [[JProductDetailModel alloc] init];
               //                                [object setValuesForKeysWithDictionary:itemData];
               //                                [mArrObject addObject:object];
               //                            }
               
               if (success) {
                   dispatch_async(dispatch_get_main_queue(), ^{
                       success(@1);
                   });
               }
           }
           else {
               NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
               dispatch_async(dispatch_get_main_queue(), ^{
                   failure(strException);
               });
           }
       } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
           NSString *strException = @"网络请求失败";

           dispatch_async(dispatch_get_main_queue(), ^{
               failure(strException);
           });
       }];
    
}

#define mark - Vendor
//Vendor/GetVendorById
///  店铺详情
+ (void)getGetVendorByIdRequedtUrl:(NSString *)url
                          verdorId:(NSInteger )verdorId
                           success:(void (^)(id response))success
                           failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = @{@"Id":@(verdorId),
                          @"CustomerId":@([GLOBALDATA userInfoModel].CustomerId),
                          @"UserId":@([GLOBALDATA userInfoModel].CustomerId)};
    
    [self requestWihtMethod:RequestMethodTypePost
                        url:dataURL
                 JsonString:dic
                    success:^(id response) {
                        NSInteger nStatus = [response[@"suc"] integerValue];
                        if (nStatus == 1) {
//                            // 列表数据
//                            NSEnumerator *enumertor = [response[@"data"] objectEnumerator];
//                            NSDictionary *itemData;
//                            NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
//                            
//                            while (itemData = (NSDictionary *)[enumertor nextObject]) {
                                JVerdorDetailModel *object = [[JVerdorDetailModel alloc] init];
                                [object setValuesForKeysWithDictionary:response[@"data"]];
//                                [mArrObject addObject:object];
//                            }
                            
                            if (success) {
                                dispatch_async(dispatch_get_main_queue(), ^{
                                    success(object);
                                });
                            }
                        }
                        else {
                            NSString *strException = [NSString stringWithFormat:@"%@", response[@"msg"]];
                            dispatch_async(dispatch_get_main_queue(), ^{
                                failure(strException);
                            });
                        }
                    } failure:^(NSError *err) {
                        NSString *strException = @"网络请求失败";
                        dispatch_async(dispatch_get_main_queue(), ^{
                            failure(strException);
                        });
                    }];
}

//Vendor/CollectVendor
///  店铺收藏 功能
+ (void)getCollectVendorRequedtUrl:(NSString *)url
                          verdorId:(NSInteger )verdorId
                           success:(void (^)(id response))success
                           failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = @{@"Id":@(verdorId),
                          @"CustomerId":@([GLOBALDATA userInfoModel].CustomerId),
                          @"UserId":@([GLOBALDATA userInfoModel].CustomerId)};
    
    [self requestWihtMethod:RequestMethodTypePost
                        url:dataURL
                 JsonString:dic
                    success:^(id response) {
                        NSInteger nStatus = [response[@"suc"] integerValue];
                        if (nStatus == 1) {
                            //                            // 列表数据
                            //                            NSEnumerator *enumertor = [response[@"data"] objectEnumerator];
                            //                            NSDictionary *itemData;
                            //                            NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
                            //
                            //                            while (itemData = (NSDictionary *)[enumertor nextObject]) {
//                            JVerdorDetailModel *object = [[JVerdorDetailModel alloc] init];
//                            [object setValuesForKeysWithDictionary:response[@"data"]];
                            //                                [mArrObject addObject:object];
                            //                            }
                            
                            if (success) {
                                dispatch_async(dispatch_get_main_queue(), ^{
                                    success(response[@"data"]);
                                });
                            }
                        }
                        else {
                            NSString *strException = [NSString stringWithFormat:@"%@", response[@"msg"]];
                            dispatch_async(dispatch_get_main_queue(), ^{
                                failure(strException);
                            });
                        }
                    } failure:^(NSError *err) {
                        NSString *strException = @"网络请求失败";
                        dispatch_async(dispatch_get_main_queue(), ^{
                            failure(strException);
                        });
                    }];
}

//Categories/GetCategoriesByVendorId
/// 店铺获取商品分类
+ (void)GetCategoriesByVendorIdRequedtUrl:(NSString *)url
                                 verdorId:(NSInteger )verdorId
                                  success:(void (^)(id response))success
                                  failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = @{@"VendorId":@(verdorId),
                          @"CustomerId":@([GLOBALDATA userInfoModel].CustomerId),
                          @"UserId":@([GLOBALDATA userInfoModel].CustomerId)};
    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:dataURL]];
    
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    
    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 20.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
#ifdef ContentType2
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
#endif
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
    //    manager.requestSerializer.timeoutInterval = 30;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
    
    [manager POST:dataURL
       parameters:dic
         progress:nil
          success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
              if (responseObject) {
                  NSInteger nStatus = [responseObject[@"suc"] integerValue];
                  if (nStatus == 1) {
                      // 列表数据
                      NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
                      NSDictionary *itemData;
                      NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
                      
                      while (itemData = (NSDictionary *)[enumertor nextObject]) {
                          JVerdorProductTypeModel *object = [[JVerdorProductTypeModel alloc] init];
                          [object setValuesForKeysWithDictionary:itemData];
                          [mArrObject addObject:object];
                      }
                      
                      if (success) {
                          dispatch_async(dispatch_get_main_queue(), ^{
                              success(mArrObject);
                          });
                      }
                  }
                  else {
                      NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
                      dispatch_async(dispatch_get_main_queue(), ^{
                          failure(strException);
                      });
                  }
              }
          } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
              NSString *strException = @"网络请求失败";
              dispatch_async(dispatch_get_main_queue(), ^{
                  failure(strException);
              });
          }];
}

//Products/GetProducts
/// 店铺获取商品
+ (void)GetVerdorProductsRequedtUrl:(NSString *)url
                           verdorId:(NSInteger )verdorId
                          pagemodel:(JGetPageModel *)pagemodel
                            success:(void (^)(id response))success
                            failure:(void (^)(NSString *err))failure
{

    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = @{@"CustomerId":@([GLOBALDATA userInfoModel].CustomerId),
                          @"UserId":@([GLOBALDATA userInfoModel].CustomerId),
                          @"VendorId":@(verdorId),
                          @"orderBy":@(pagemodel.orderBy),
                          @"pageIndex":@(pagemodel.pageIndex),
                          @"pageSize":@(pagemodel.pageSize)};
    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:dataURL]];
    
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    
    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 20.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
#ifdef ContentType2
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
#endif
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
    //    manager.requestSerializer.timeoutInterval = 30;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
    
    [manager POST:dataURL
       parameters:dic
         progress:nil
          success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
              if (responseObject) {
                  NSInteger nStatus = [responseObject[@"suc"] integerValue];
                  if (nStatus == 1) {
                      // 列表数据
                    NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
                    NSDictionary *itemData;
                    NSMutableArray *mArrObject = [[NSMutableArray alloc] init];

                    while (itemData = (NSDictionary *)[enumertor nextObject]) {
                        JProductDetailModel *object = [[JProductDetailModel alloc] init];
                        [object setValuesForKeysWithDictionary:itemData];
                        [mArrObject addObject:object];
                    }
                      
                      if (success) {
                          dispatch_async(dispatch_get_main_queue(), ^{
                              success(mArrObject);
                          });
                      }
                  }
                  else {
                      NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
                      dispatch_async(dispatch_get_main_queue(), ^{
                          failure(strException);
                      });
                  }
              }
          } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
              NSString *strException = @"网络请求失败";
              dispatch_async(dispatch_get_main_queue(), ^{
                  failure(strException);
              });
          }];
}

#define mark - cuthair request
//BarberSh/GetSearchBarberShop
/// 理发店商品请求
+ (void)GetCutHairShopProductsRequedtUrl:(NSString *)url
                        parameModel:(JCutHairRequestModel *)parameModel
                            success:(void (^)(id response))success
                            failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = parameModel.mj_keyValues;
    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:dataURL]];
    
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    
    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 20.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
#ifdef ContentType2
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
#endif
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
    //    manager.requestSerializer.timeoutInterval = 30;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
    
    [manager POST:dataURL
       parameters:dic
         progress:nil
          success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
              if (responseObject) {
                  NSInteger nStatus = [responseObject[@"suc"] integerValue];
                  if (nStatus == 1) {
                      // 列表数据
//                      NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
//                      NSDictionary *itemData;
//                      NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
                      
//                      while (itemData = (NSDictionary *)[enumertor nextObject]) {
                          JCutHairShopModel *object = [[JCutHairShopModel alloc] init];
                          [object setValuesForKeysWithDictionary:responseObject[@"data"]];
//                          [mArrObject addObject:object];
//                      }
                      
                      if (success) {
                          dispatch_async(dispatch_get_main_queue(), ^{
                              success(object);
                          });
                      }
                  }
                  else {
                      NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
                      dispatch_async(dispatch_get_main_queue(), ^{
                          failure(strException);
                      });
                  }
              }
          } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
              NSString *strException = @"网络请求失败";
              dispatch_async(dispatch_get_main_queue(), ^{
                  failure(strException);
              });
          }];
}

//BarberSh/GetAreasByCity
/// 理发店地区请求
+ (void)GetCutHairShopCityRequedtUrl:(NSString *)url
                         shopNameTip:(NSString *)shopNameTip
                             success:(void (^)(id response))success
                             failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = @{@"ShopNameTip":shopNameTip,
                          @"CustomerId":@([GLOBALDATA userInfoModel].CustomerId),
                          @"UserId":@([GLOBALDATA userInfoModel].CustomerId)};
    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:dataURL]];
    
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    
    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 20.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
#ifdef ContentType2
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
#endif
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
    //    manager.requestSerializer.timeoutInterval = 30;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
    
    [manager POST:dataURL
       parameters:dic
         progress:nil
          success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
              if (responseObject) {
                  NSInteger nStatus = [responseObject[@"suc"] integerValue];
                  if (nStatus == 1) {
                      // 列表数据
                      //                      NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
                      //                      NSDictionary *itemData;
                      //                      NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
                      
                      //                      while (itemData = (NSDictionary *)[enumertor nextObject]) {
//                      JCutHairShopModel *object = [[JCutHairShopModel alloc] init];
//                      [object setValuesForKeysWithDictionary:responseObject[@"data"]];
                      //                          [mArrObject addObject:object];
                      //                      }
                      
                      if (success) {
                          dispatch_async(dispatch_get_main_queue(), ^{
                              success(responseObject[@"data"]);
                          });
                      }
                  }
                  else {
                      NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
                      dispatch_async(dispatch_get_main_queue(), ^{
                          failure(strException);
                      });
                  }
              }
          } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
              NSString *strException = @"网络请求失败";
              dispatch_async(dispatch_get_main_queue(), ^{
                  failure(strException);
              });
          }];
}


//Orders/GetMsgsCount
/// 理发店信息请求
+ (void)GetCutHairShopMsgsCountRequedtUrl:(NSString *)url
                                  success:(void (^)(id response))success
                                  failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = @{@"CustomerId":@([GLOBALDATA userInfoModel].CustomerId),
                          @"UserId":@([GLOBALDATA userInfoModel].CustomerId)};
    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:dataURL]];
    
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    
    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 20.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
#ifdef ContentType2
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
#endif
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
    //    manager.requestSerializer.timeoutInterval = 30;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json", @"text/javascript", nil];
    
    [manager POST:dataURL
       parameters:dic
         progress:nil
          success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
              if (responseObject) {
                  NSInteger nStatus = [responseObject[@"suc"] integerValue];
                  if (nStatus == 1) {
                      // 列表数据
                      //                      NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
                      //                      NSDictionary *itemData;
                      //                      NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
                      
                      //                      while (itemData = (NSDictionary *)[enumertor nextObject]) {
                      //                      JCutHairShopModel *object = [[JCutHairShopModel alloc] init];
                      //                      [object setValuesForKeysWithDictionary:responseObject[@"data"]];
                      //                          [mArrObject addObject:object];
                      //                      }
                      
                      if (success) {
                          dispatch_async(dispatch_get_main_queue(), ^{
                              success(responseObject[@"data"]);
                          });
                      }
                  }
                  else {
                      NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
                      dispatch_async(dispatch_get_main_queue(), ^{
                          failure(strException);
                      });
                  }
              }
          } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
              NSString *strException = @"网络请求失败";
              dispatch_async(dispatch_get_main_queue(), ^{
                  failure(strException);
              });
          }];
}

#define mark - beautiful
//Cirle/AddSocialHub
/// 创建圈聊
+ (void)subBeautifulSocialHubRequedtUrl:(NSString *)url
                                 dicPar:(NSDictionary *)dic
                                success:(void (^)(id response))success
                                failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    
//    NSString *picStr = [self convertToJsonData:dic];
    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:dataURL]];
    
//    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/xml"];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    manager.responseSerializer = [AFJSONResponseSerializer serializer];
    
    manager.securityPolicy = [AFSecurityPolicy defaultPolicy];
    manager.securityPolicy.allowInvalidCertificates = YES;
    manager.securityPolicy.validatesDomainName = NO;
    [manager.requestSerializer willChangeValueForKey:@"timeoutInterval"];//设置超时时间
    manager.requestSerializer.timeoutInterval = 20.f;
    [manager.requestSerializer didChangeValueForKey:@"timeoutInterval"];
    
    //关闭缓存避免干扰测试
    manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    
#ifdef ContentType2
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:ContentType2];
#endif
    manager.requestSerializer.HTTPShouldHandleCookies = YES;
    //    manager.requestSerializer.timeoutInterval = 30;
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html",@"text/json",@"text/xml",@"text/plain", @"text/javascript", nil];
//    
    [manager POST:dataURL parameters:dic
         progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
             if (responseObject) {
                 NSInteger nStatus = [responseObject[@"suc"] integerValue];
                 if (nStatus == 1) {
                     // 列表数据
                     //                      NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
                     //                      NSDictionary *itemData;
                     //                      NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
                     
                     //                      while (itemData = (NSDictionary *)[enumertor nextObject]) {
                     //                      JCutHairShopModel *object = [[JCutHairShopModel alloc] init];
                     //                      [object setValuesForKeysWithDictionary:responseObject[@"data"]];
                     //                          [mArrObject addObject:object];
                     //                      }
                     
                     if (success) {
                         dispatch_async(dispatch_get_main_queue(), ^{
                             success(@1);
                         });
                     }
                 }
                 else {
                     NSString *strException = [NSString stringWithFormat:@"%@", responseObject[@"msg"]];
                     dispatch_async(dispatch_get_main_queue(), ^{
                         failure(strException);
                     });
                 }
             }
         } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
             NSString *strException = @"网络请求失败";
             dispatch_async(dispatch_get_main_queue(), ^{
                 failure(strException);
             });
         }];

}

//Cirle/GetSocialHubNotes
/// 网聊协议
+ (void)GetGetSocialHubNotesRequedtUrl:(NSString *)url
                               success:(void (^)(id response))success
                               failure:(void (^)(NSString *err))failure
{
    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
    NSDictionary *dic = @{@"CustomerId":@([GLOBALDATA userInfoModel].CustomerId),
                          @"UserId":@([GLOBALDATA userInfoModel].CustomerId),
                          @"Name":@"网聊协议"};
    [self requestWihtMethod:RequestMethodTypePost
                        url:dataURL
                 JsonString:dic
                    success:^(id response) {
                        if (response) {
                            NSInteger nStatus = [response[@"suc"] integerValue];
                            if (nStatus == 1) {
                                // 列表数据
                                //                      NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
                                //                      NSDictionary *itemData;
                                //                      NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
                                
                                //                      while (itemData = (NSDictionary *)[enumertor nextObject]) {
                                //                      JCutHairShopModel *object = [[JCutHairShopModel alloc] init];
                                //                      [object setValuesForKeysWithDictionary:responseObject[@"data"]];
                                //                          [mArrObject addObject:object];
                                //                      }
                                
                                if (success) {
                                    dispatch_async(dispatch_get_main_queue(), ^{
                                        success(response[@"data"]);
                                    });
                                }
                            }
                            else {
                                NSString *strException = [NSString stringWithFormat:@"%@", response[@"msg"]];
                                dispatch_async(dispatch_get_main_queue(), ^{
                                    failure(strException);
                                });
                            }
                        }
                    } failure:^(NSError *err) {
                        NSString *strException = @"网络请求失败";
                        dispatch_async(dispatch_get_main_queue(), ^{
                            failure(strException);
                        });
                    }];
}

////TimeShow/AddTimeShow
///// 创建日记
//+ (void)subBeautifulAddTimeShowRequedtUrl:(NSString *)url
//                                   dicPar:(NSDictionary *)dic
//                                  success:(void (^)(id response))success
//                                  failure:(void (^)(NSString *err))failure
//{
//    NSString *dataURL = [NSString stringWithFormat:@"%@/%@",JNetAPI,url];
//    [self requestWihtMethod:RequestMethodTypePost
//                        url:dataURL
//                 JsonString:dic
//                    success:^(id response) {
//                        if (response) {
//                            NSInteger nStatus = [response[@"suc"] integerValue];
//                            if (nStatus == 1) {
//                                // 列表数据
//                                //                      NSEnumerator *enumertor = [responseObject[@"data"] objectEnumerator];
//                                //                      NSDictionary *itemData;
//                                //                      NSMutableArray *mArrObject = [[NSMutableArray alloc] init];
//                                
//                                //                      while (itemData = (NSDictionary *)[enumertor nextObject]) {
//                                //                      JCutHairShopModel *object = [[JCutHairShopModel alloc] init];
//                                //                      [object setValuesForKeysWithDictionary:responseObject[@"data"]];
//                                //                          [mArrObject addObject:object];
//                                //                      }
//                                
//                                if (success) {
//                                    dispatch_async(dispatch_get_main_queue(), ^{
//                                        success(@1);
//                                    });
//                                }
//                            }
//                            else {
//                                NSString *strException = [NSString stringWithFormat:@"%@", response[@"msg"]];
//                                dispatch_async(dispatch_get_main_queue(), ^{
//                                    failure(strException);
//                                });
//                            }
//                        }
//                    } failure:^(NSError *err) {
//                        NSString *strException = @"网络请求失败";
//                        dispatch_async(dispatch_get_main_queue(), ^{
//                            failure(strException);
//                        });
//                    }];
//}

+(NSString *)convertToJsonData:(NSDictionary *)dict

{
    
    NSError *error;
    
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:&error];
    
    NSString *jsonString;
    
    if (!jsonData) {
        
        NSLog(@"%@",error);
        
    }else{
        
        jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
        
    }
    
    NSMutableString *mutStr = [NSMutableString stringWithString:jsonString];
    
    NSRange range = {0,jsonString.length};
    
    //去掉字符串中的空格
    
    [mutStr replaceOccurrencesOfString:@" " withString:@"" options:NSLiteralSearch range:range];
    
    NSRange range2 = {0,mutStr.length};
    
    //去掉字符串中的换行符
    
    [mutStr replaceOccurrencesOfString:@"\n" withString:@"" options:NSLiteralSearch range:range2];
    
    return mutStr;
    
}

@end
